#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
struct car
{
    int dd,vv,aa;
}a[N];
int t,n,m,l,v,su[N];
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int i,j,ans=0,tim=0;
    cin>>t;
    while(t--)
    {
        ans=0;
        cin>>n>>m>>l>>v;
        for(i=1;i<=n;i++)   cin>>a[i].dd>>a[i].vv>>a[i].aa;
        for(i=1;i<=m;i++)   cin>>su[i];
        for(i=1;i<=n;i++)
        {
            if(a[i].vv>v)
            {
                for(j=1;j<=m;j++)
                {
                    if(su[j]>=a[i].dd)
                    {
                        ans++;
                        break;
                    }
                }
            }
        }
        cout<<ans<<" "<<m-1;
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}
